package br.pucrio.inf.lac.konoha.hyuga.common;

import java.io.Serializable;

public class Pair<F, S> implements Serializable {
    private static final long serialVersionUID = 1L;
    
    public final F first;
    public final S second;

    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return p.first.equals(first) && p.second.equals(second);
    }
    
    @Override
    public String toString() {
        return "(" + first + ", " + second + ")";
    }
    
    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    // Helpers
    public static <A, B> Pair <A, B> create(A a, B b) {
    	return new Pair<A, B>(a, b);
    }
    
    // Getters    
    public F getFirst() {
        return first;
    }
    
    public S getSecond() {
        return second;
    }
    
}